package com.health.controller;

import com.health.vo.Result;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    @RequestMapping("/loginSuccess")
    public Result loginSuccess() {
        //获取当前登录用户的用户名
        String username = SecurityContextHolder.getContext().getAuthentication().getName();
        return new Result(true, "登陆成功", username);
    }

    @RequestMapping("/loginFail")
    public Result loginFail() {
        return new Result(false, "用户名或密码输入错误");
    }
}
